<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    //ES6新增let命令，用来声明变量，用法和var类似，但是所声明的变量，只在let所在的代码块有效
    {
      let a = 10;
      var b = 1;
    }
    // Uncaught ReferenceError: a is not defined
    //console.log(a);
    console.log(b);

    for (let i = 0; i < 10; i++) {
      //...
    }
    //console.log(i);//i is not defined
  </script>
</body>
</html>